#ifndef __IO
#define __IO 4


extern bit flag_red_lamp_on;
extern bit flag_green_lamp_on;
extern bit flag_yellow_lamp_on;

extern bit flag_red_lamp_blink;
extern bit flag_green_lamp_blink;
extern bit flag_yellow_lamp_blink;


extern void ServiceLamps(void);
extern void ServiceInputs(void);

extern void ConnectSupply(void);
extern void DisconnectSupply(void);

extern void ConnectHPS(void);
extern void DisconnectHPS(void);

extern void ConnectCOM(void);
extern void DisconnectCOM(void);

extern unsigned char SupplyPresent(void);
extern unsigned char ComInDanger(void);

extern unsigned char StartButtonPressed(void);
extern unsigned char StopButtonPressed(void);

extern unsigned char EEVState(void);
extern unsigned char RVState(void);



#define LAMP_BLINK_PERIOD 200

#define OUTPORT PORTB

#define INPORT PORTD

#define InitIO()  PORTB=0;TRISB=0xC0;TRISA=0xEF;TRISE=0;PORTD=0;TRISD=0xFF


#define Green_lamp_blink()  flag_green_lamp_on=1;\
							flag_green_lamp_blink=1

#define Green_lamp_on()		flag_green_lamp_on=1; \
							flag_green_lamp_blink=0

#define Green_lamp_off()	flag_green_lamp_on=0;\
							flag_green_lamp_blink=0

#define Red_lamp_blink() 	flag_red_lamp_on=1; \
							flag_red_lamp_blink=1

#define Red_lamp_on()		flag_red_lamp_on=1; \
							flag_red_lamp_blink=0

#define Red_lamp_off()		flag_red_lamp_on=0; \
							flag_red_lamp_blink=0


#define Yellow_lamp_blink() 	flag_yellow_lamp_on=1; \
							flag_yellow_lamp_blink=1

#define Yellow_lamp_on()		flag_yellow_lamp_on=1; \
							flag_yellow_lamp_blink=0

#define Yellow_lamp_off()		flag_yellow_lamp_on=0; \
							flag_yellow_lamp_blink=0


#endif

